package com.qingcheng.service.impl;


import com.qingcheng.service.goods.BrandService;
import com.qingcheng.service.goods.CategoryService;
import com.qingcheng.service.goods.SkuService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class Init implements InitializingBean {

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private BrandService brandService;


    @Autowired
    private SkuService skuService;

    @Override
    public void afterPropertiesSet() throws Exception {
        /*Tomcat启动时，自动被触发*/
        System.out.println("缓存预热");
        //加载商品分类导航缓存
        categoryService.saveCategoryTreeToRedis();
        //加载价格数据
        skuService.saveAllPriceToRedis();
        //加载品牌列表
        brandService.saveBrandTreeToRedis();




    }
}
